package com.test;

import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

class Solution {
    public int removeDuplicates(int[] nums) {
    	
    	Set<Integer> setNums=new HashSet<Integer>();
    	
    	if(nums==null || nums.length==0)
    	{
    		return 0;
    	}
    	
    	int count=0;
    	for(int n : nums)
    	{
    		if(setNums.add(n))
    		{
    			nums[count++]=n;
    		}
    	}
    	
    	
    	return count;
    }
}

public class testaa {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		int[] n=new int[] {1,1,2};
		System.out.println(new Solution().removeDuplicates(n));

		for(int i=0;i<n.length;++i)
		{
			System.out.println(n[i]+ "\t");
		}
	}

}